﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EFGhh.chapater3.Model;

namespace EFGhh.chapater3
{
    public partial class Insert : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_baocun_Click(object sender, EventArgs e)
        {
            if (tx_title.Text == "" || tx_content.Text == "")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "提示", "alert('标题和内容不能为空!')", true);
                return;
            }
            Topic data = new Topic()
            {
                Title = tx_title.Text,
                Content = tx_content.Text,
                IPAddress = ".32",
                UpdateTime = DateTime.Now
            };
            using (FAQDBEntities db = new FAQDBEntities())
            {

                db.Topics.Add(data);
                db.SaveChanges();
                Response.Redirect("Index.aspx");
            }
        }

        protected void btn_fanhui_Click(object sender, EventArgs e)
        {
            Response.Redirect("Index.aspx");
        }
    }
}